import React, { Component } from "react"
import Styles from '@/scss/lefts.scss'
import { inject, observer } from "mobx-react"
//引入自己的组件
import Search from "@/pages/components/lefts/search"
import LeftNav from "@/pages/components/lefts/leftnav"

//左边导航栏入口组件
@inject('store')
@observer
class Lefts extends Component<IStorePropsType, any>{
  //一、回车与点击搜索事件，（直接加到了onChange中了）
  onSearch = (e: any) => {
    let evt = window.event || e;
    if (!evt.keyCode || evt.keyCode == 13) this.props.store.handleSrarch(e.target.value)
  }
  //点击切换显示页面 并且清空待选
  handleIsShow = (isshow: string) => {
    if (isshow != this.props.store.isShow) {
      this.props.store.handleBatchdel(false)
      this.props.store.clearBatchdelsNoDel()
      this.props.store.handleIsShow(isshow)
    }
  }
  render() {
    return (
      <div className={Styles.left_box}>
        {//引入搜索组件,传入一个搜索事件
          <Search onSearch={this.onSearch} />
        }
        {//引入左边导航栏组件,此处我发现,当没有用inject去监听的不能直接调用store的action,调用父类传入的方法,否则报错
          <LeftNav isShow={this.props.store.isShow} handleIsShow={this.handleIsShow} />
        }
      </div>
    )
  }

}


export default Lefts




